package com.xinxin.socket.sample.webserver;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;

@Slf4j
@Path("server")
public class CommonCgi {

    @GET()
    @Path("test")
    public String test(@QueryParam("param") String param) {
        return param;
    }

    @POST()
    @Path("marsUpdateUserState")
    public String marsUpdateUserState(String params) {
        try {
            JSONObject jsonObject = JSONObject.parseObject(params);
            Long userId = jsonObject.getLong("userId");
            int cmdId = jsonObject.getInteger("cmdId");
            log.info("userId: {}, cmdId: {}", userId, cmdId);
        } catch (Exception ignored) {
        }

        return "OK";
    }
}
